package com.myhome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myhome.mapper.ConfigMapper;
import com.myhome.domain.Config;
import com.myhome.service.ConfigService;
import org.springframework.util.StringUtils;

/**
*@Author QYiXin 
* @Date 2021 10 23 22 55
**/
@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService{

    @Override
    public Config getConfigByCode(String code) {
        Config config = this.getOne(new LambdaQueryWrapper<Config>().eq(!StringUtils.isEmpty(code), Config::getCode, code));
        if (config == null) {
            throw new IllegalArgumentException("该配置不存在");
        }
        return config;

    }
}
